package com.gensdai.leliang.adapter;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.gensdai.leliang.R;
import com.gensdai.leliang.entity.parseBean.BaseParse;
import com.gensdai.leliang.remoteInterface.URLConfig;
import com.gensdai.leliang.utils.ViewHolder;

/**
 * 订单详情里面产品的列表 适配器
 * Created by Administrator on 2017/6/9.
 */

public class SimpleOrderInfoProductListAdapter extends KimiraAdapter<BaseParse.OrderAttributeMapBean> {

    LayoutInflater inflater;
    Context context;


    public SimpleOrderInfoProductListAdapter(Context context) {
        inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.context = context;
    }

    @Override
    public View extralView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_simple_order_info_product_list,
                    null);
        }

        SimpleDraweeView icon = ViewHolder.GetChars(convertView, R.id.productIcon);
        TextView productName = ViewHolder.GetChars(convertView, R.id.title);
        TextView productAttr = ViewHolder.GetChars(convertView, R.id.info);

        BaseParse.OrderAttributeMapBean bean = (BaseParse.OrderAttributeMapBean) getItem(position);

        String imguri = "";
        if (!TextUtils.isEmpty(bean.logo)) {
            imguri = URLConfig.BASEDOMAIN + bean.logo;
        }
        icon.setImageURI(Uri.parse(imguri));
        productName.setText(bean.productName);
        productAttr.setText(bean.attributeName == null ? "" : "商品分类" + bean.attributeName);
        return convertView;
    }
}
